package com.ji.securityuaa.service.impl;

import com.ji.securityuaa.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @Auther: jiliugang
 * @Date: 2020/6/28 09:28
 * @Description:
 */
@Service
public class UserServiceImpl implements UserService, UserDetailsService {
    @Autowired
    private BCryptPasswordEncoder bCryptPasswordEncoder;
    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        if (!"admin".equals(s)){
            return null;
        }
        UserDetails userDetails = User.withUsername(s).password("$2a$10$pAN5gMo0u/NqZU2x1nyc9u0miYW.K57HMcvLCg94uNpRq4CVVZqZa")
                .authorities("p1","p2").build();
        return userDetails;
    }
}
